#include <iostream>

using namespace std;
int n;
long long a[100010];
int tmp[100010];
long long sum = 0;

void merge_sort(long long a[], int l, int r)
{
    if (l >= r)
        return;
    int mid = (l + r) /2 ;                           // 1.找临界点
    merge_sort(a, l, mid);
    merge_sort(a, mid + 1, r); // 2.递归向下分，log2,把一个序列分成左右两个序列，一直到最后每个序列只有一个数
    int i = l, j = mid + 1, k = 0;                    // 3.合并:左右两个序列进行合并
    while (i <= mid && j <= r)
        if (a[i] <= a[j])
            tmp[k++] = a[i++];
        else
        {
            tmp[k++] = a[j++];
            sum += mid + 1 - i;
        } // 4.如果a[i]>a[j]&&i<j 符合逆序对条件，那么计数(a[i]与a[j]构成逆序对，那么i后面的数一定也与a[j]构成逆序对)
    while (i <= mid)
        tmp[k++] = a[i++]; //所以统计的是sum+=mid-i+1;
    while (j <= r)
        tmp[k++] = a[j++];
    for (int i = l, j = 0; i <= r; i++, j++)
        a[i] = tmp[j];
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    merge_sort(a, 1, n );
    cout << sum << endl;
    system("pause");
    return 0;
}